/*
	This file is part of AVRCppLib.

    AVRCppLib is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    AVRCppLib is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with AVRCppLib.  If not, see <http://www.gnu.org/licenses/>.

    Copyright (C) Maxime Lemonnier 2007-2011
 */

#ifndef STRINGBUFFERTEST_H_
#define STRINGBUFFERTEST_H_


#include "DataStructures/Queue.h"
#include "DataStructures/StringBuffer.h"
#include "TestCase.h"
#include "Utils/Utils.h"

class StringBufferTest :  public TestCase<StringBufferTest>
{

	const prog_mem * el0;
	const prog_mem * el1;
	const prog_mem * el2;
	StringBuffer * buffer;

public:


	StringBufferTest(const prog_mem * testMethodName_P, TestCase<StringBufferTest>::TestMethod testMethod) :
	TestCase<StringBufferTest>(testMethodName_P, testMethod),
	el0(PROG_MEM_STRING("const prog_mem *1")), el1(PROG_MEM_STRING("const prog_mem *2")), el2(PROG_MEM_STRING("const prog_mem *3"))
	{

	}

	void setUp()
	{
		buffer = new StringBuffer(10);
	}
	void tearDown()
	{
		delete buffer;
	}

	bool testoperators()
	{
		const char * string = "const string";

		StringBuffer q(20);

		q << string;

		char * qString = NULL;

		qString << q;

		bool result = AVRUNIT_ASSERT_EQUALS_STRING(qString, string);


		const prog_mem * string_P = PROG_MEM_STRING("testoperators");

		q.init();

		q << string_P;

		qString << q;

		result &= AVRUNIT_ASSERT_EQUALS_STRING_P(qString, string_P);

		return result;

	}

};

#endif /* STRINGBUFFERTEST_H_ */
